<?php
/**
 * @see Alinks_Form_Element_Abstract
 */
require_once('Alinks/Form/Element/Abstract.php');

/**
 * Represents a form text element
 *
 * Copyright (C) 2008  Sean Hickey
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @author Sean Hickey <sean@headzoo.com>
 * @version $Id: Text.php 378 2008-07-03 05:19:31Z sean $
 * @package Alinks_Form
 */
class Alinks_Form_Element_Text extends Alinks_Form_Element_Abstract
{
	/**
	 * Constructor
	 *
	 * @param string $name The name of the form element
	 * @param array $args The input arguments
	 * @param string $label The input label
	 */
	public function __construct($name = null, $args = array(), $label = null)
	{
		$this->setName($name);
		$this->setArgs((array)$args);
		$this->setLabel($label);
	}
	
	/**
	 * Returns the HTML for the form element
	 *
	 * @return string
	 */
	public function getHtml()
	{
		return sprintf('<input type="text" name="%s" id="%s" %s value="%s" />',
			$this->getName(), $this->getId(), $this->_argsToString(), htmlspecialchars($this->getValue()));
	}
}